﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace assignment5
{
    class program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int choice;
                Console.WriteLine("输入1添加订单，输入2删除订单，" +
                    "输入3修改订单，输入4查询订单，输入5查询订单详细信息，输入6退出控制台程序");
                choice = Int32.Parse(Console.ReadLine());
                OrderService os = new OrderService();
                switch (choice)
                {
                    case 1:
                        Console.WriteLine("请输入一组订单数据（id，客户，总金额）");
                        int orderID = Int32.Parse(Console.ReadLine());
                        string customer = Console.ReadLine();
                        int totalMoney = Int32.Parse(Console.ReadLine());
                        Order order = new Order(orderID, customer, totalMoney);

                        Console.WriteLine("请输入此订单的详细信息(商品数量，商品名称，商品单价)");
                        int num = Int32.Parse(Console.ReadLine());
                        string name = Console.ReadLine();
                        int price = Int32.Parse(Console.ReadLine());
                        OrderDetails detail = new OrderDetails(num,name,price);
                        order.AddOrderDetails(order,detail);
                        os.AddOrder(order);
                        break;
                    case 2:
                        Console.WriteLine("请输入需删除订单的编号");
                        int num1 = Int32.Parse(Console.ReadLine());
                        os.DeleteOrder(num1);
                        break;
                    case 3:
                        Console.WriteLine("请输入需修改订单的全部信息（id，客户名，总金额）");
                        int id1 = Int32.Parse(Console.ReadLine());
                        string customer1 = Console.ReadLine();
                        int totalMoney1 = Int32.Parse(Console.ReadLine());
                        Order order1 = new Order(id1, customer1, totalMoney1);
                        os.ChangeOrder(order1);
                        break;
                    case 4:
                        Console.WriteLine("请输入查询订单方式：输入1通过订单号查询；" +
                            "输入2通过商品名称查询；输入3通过客户名查询；输入4通过总金额查询");
                        int id = Int32.Parse(Console.ReadLine());
                        os.SearchOrder(id);
                        break;
                    case 5:
                        Console.WriteLine("请输入需查询详细信息的订单号");
                        int id2 = Int32.Parse(Console.ReadLine());
                        os.SearchOrderDetails(id2);
                        break;
                    case 6:
                        Console.WriteLine("退出程序");
                        Environment.Exit(0);
                        break;
                }
            }
            
        }

    }

}
